home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
- Begin VB.Form frmMain
- BorderStyle = 3 'Fixed Dialog
- Caption = "Sort Solution Visual Basic Sample"
- ClientHeight = 5625
- ClientLeft = 45
- ClientTop = 300
- ClientWidth = 6870
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 221.894
- ScaleMode = 0 'User
- ScaleWidth = 100
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 'CenterScreen
- Begin VB.CommandButton EditCommandFile
- Caption = "&Edit..."
- Height = 495
- Left = 3120
- TabIndex = 10
- ToolTipText = "Edit the profile"
- Top = 1080
- Width = 1575
- End
- Begin ComctlLib.ProgressBar ProgressMerge
- Height = 255
- Left = 240
- TabIndex = 8
- Top = 3000
- Width = 5895
- _ExtentX = 10398
- _ExtentY = 450
- _Version = 327682
- Appearance = 0
- End
- Begin ComctlLib.ProgressBar ProgressSort
- Height = 255
- Left = 240
- TabIndex = 6
- Top = 2280
- Width = 5895
- _ExtentX = 10398
- _ExtentY = 450
- _Version = 327682
- Appearance = 0
- End
- Begin VB.CommandButton ManualSort
- Caption = "Test the &Manual Sort"
- Height = 615
- Left = 240
- TabIndex = 5
- ToolTipText = "Execute a sort with SSICreateFromCommandString"
- Top = 4080
- Width = 3855
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 4800
- Top = 960
- _ExtentX = 847
- _ExtentY = 847
- _Version = 327681
- End
- Begin VB.CommandButton Browse
- Caption = "&Browse..."
- Height = 375
- Left = 4800
- TabIndex = 4
- ToolTipText = "Browse for profiles"
- Top = 480
- Width = 1335
- End
- Begin VB.TextBox Filename
- Height = 375
- Left = 240
- TabIndex = 2
- ToolTipText = "Select a command file"
- Top = 480
- Width = 4455
- End
- Begin VB.CommandButton Run
- Caption = "&Execute"
- Height = 495
- Left = 240
- TabIndex = 1
- ToolTipText = "Execute the sort"
- Top = 1080
- Width = 1815
- End
- Begin ComctlLib.StatusBar sbStatusBar
- Align = 2 'Align Bottom
- Height = 270
- Left = 0
- TabIndex = 0
- Top = 5355
- Width = 6870
- _ExtentX = 12118
- _ExtentY = 476
- SimpleText = ""
- _Version = 327682
- BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
- NumPanels = 2
- BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
- AutoSize = 1
- Object.Width = 9499
- Text = "Status"
- TextSave = "Status"
- Key = ""
- Object.Tag = ""
- EndProperty
- BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
- Style = 5
- TextSave = "23:21"
- Key = ""
- Object.Tag = ""
- EndProperty
- EndProperty
- End
- Begin VB.Label VersionString
- Caption = "Version"
- Height = 255
- Left = 240
- TabIndex = 11
- Top = 4920
- Width = 5655
- End
- Begin VB.Label Label3
- Caption = "Merge Progress"
- Height = 255
- Left = 240
- TabIndex = 9
- Top = 2640
- Width = 2295
- End
- Begin VB.Label Label2
- Caption = "Sort Progress:"
- Height = 255
- Left = 240
- TabIndex = 7
- Top = 1920
- Width = 2295
- End
- Begin VB.Label Label1
- Caption = "&Profile:"
- Height = 255
- Left = 240
- TabIndex = 3
- Top = 120
- Width = 3855
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- ' Look in the function Run_Click() to see how the
- ' Sort Solution library is integrated into this sample
- Private Sub Browse_Click()
- CommonDialog1.CancelError = True
- On Error GoTo ErrHandler
- CommonDialog1.Filter = "Profiles (*.ssp)|*.ssp"
- CommonDialog1.ShowOpen
- Filename = CommonDialog1.Filename
- Exit Sub
- ErrHandler:
- Exit Sub
- End Sub
- ' Edit the current profile
- Private Sub EditCommandFile_Click()
- Dim result As Double
- result = Shell("notepad.exe " & Filename, vbNormalFocus)
- End Sub
- Private Sub Filename_Change()
- If (Filename = "") Then
- Run.Enabled = False
- EditCommandFile.Enabled = False
- Else
- Run.Enabled = True
- EditCommandFile.Enabled = True
- End If
- End Sub
- ' A helper function for SSIGetVersion
- Private Function HIWORD(X As Long) As Integer
- HIWORD = X \ &HFFFF&
- End Function
- ' A helper function for SSIGetVersion
- Private Function LOWORD(X As Long) As Integer
- LOWORD = X And &HFFFF&
- End Function
- Private Sub Form_Load()
- Dim result As Long
- Dim lo As Long
- Dim hi As Long
- Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
- Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
- Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
- Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
- Run.Enabled = False
- EditCommandFile.Enabled = False
- ProgressSort.Min = 0
- ProgressSort.Max = 100
- ProgressMerge.Min = 0
- ProgressMerge.Max = 100
- ' Retrieve the version information from the DLL
- result = SSIGetVersion(hi, lo)
- VersionString = "Sort Solution Version: " & HIWORD(hi) & "." & LOWORD(hi) & ", Build " & HIWORD(lo)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim i As Integer
- 'close all sub forms
- For i = Forms.Count - 1 To 1 Step -1
- Unload Forms(i)
- Next
- If Me.WindowState <> vbMinimized Then
- SaveSetting App.Title, "Settings", "MainLeft", Me.Left
- SaveSetting App.Title, "Settings", "MainTop", Me.Top
- SaveSetting App.Title, "Settings", "MainWidth", Me.Width
- SaveSetting App.Title, "Settings", "MainHeight", Me.Height
- End If
- End Sub
- ' Display an Sort Solution error message for "SoSoCode"
- Private Sub ShowErrorMessage(SoSoCode As Long)
- Dim result As Long
- Dim msg As String
- msg = String$(255, 0)
- result = SSIGetErrorMessage(SoSoCode, msg, 255)
- MsgBox msg, , "Sort Solution Error"
- End Sub
- Private Sub Label4_Click()
- End Sub
- ' This sub performs all steps required to use the Sort Solution engine
- ' in your application. Please read the comments for more information
- Private Sub Run_Click()
- Dim handle As Long
- Dim result As Long
- Dim cmdstate As SORTSOL_CMDFILESTATUS
- Dim stats As SORTSOL_STATS
-
- ' Set the Size member of both structures
- cmdstate.Size = Len(cmdstate)
- ' Wichtig: Dieses Element mu
- mit False initialisiert
- ' sein um unabsichtliches
- berschreiben der Einstellungen
- ' aus der Pofildatei zu vermeiden
- cmdstate.Override = False
- stats.Size = Len(stats)
- ' Reset the progres bars
- ProgressSort.Value = 0
- ProgressMerge.Value = 0
- Dim xlen As Long
- xlen = Len(stats)
- ' Create a sort instance from the profile "Filename"
- result = SSICreateFromFile(handle, Filename, cmdstate)
- If (result <> SOSOERR_SUCCESS) Then
- ' If we have an error, get the corresponding message
- ' from the library, display it and then return
- ShowErrorMessage (result)
- Exit Sub
- End If
- ' Change the mouse pointer to give some visual feedback
- MousePointer = vbHourglass
- result = SSIRegisterCallback(handle, AddressOf MySortCallback, 0)
- ' And now execute the sort...
- result = SSISort(handle)
- If (result <> SOSOERR_SUCCESS) Then
- ShowErrorMessage (result)
- ' Don't forget to free the sort in this case
- result = SSIFree(handle)
- MousePointer = vbDefault
- Exit Sub
- End If
-
- ' Get some statistical information
- result = SSIGetStats(handle, stats)
- If (result <> SOSOERR_SUCCESS) Then
- ShowErrorMessage (result)
- End If
- ' Free the sort instance
- result = SSIFree(handle)
- If (result <> SOSOERR_SUCCESS) Then
- ShowErrorMessage (result)
- End If
- MousePointer = vbDefault
- ' Display some statistical information
- MsgBox "Sort completed in " & CLng((stats.SortTime + stats.MergeTime) / 1000) & " seconds." & _
- Chr(13) & Chr(10) & Format(stats.BytesSortedLo, "##,##0") & " bytes processed." & _
- Chr(13) & Chr(10) & Format(stats.RecordsProcessedLo, "##,##0") & " records processed." & _
- Chr(13) & Chr(10) & Format(stats.RecordsFilteredLo, "##,##0") & " records filtered."
- End Sub
- ' This sub shows how to sort using a a command string
- Private Sub ManualSort_Click()
- Dim command As String
- Dim handle As Long
- Dim cmdstate As SORTSOL_CMDFILESTATUS
- Dim result As Long
- ' Set the Size member of both structures
- cmdstate.Size = Len(cmdstate)
- ' Set the file names for input and output here
- Const INPUT_FILE_NAME As String = "sort.dat"
- Const OUTPUT_FILE_NAME As String = "sort.out"
- ' Each line in the command string must contain a Carriage Return/Linefeed pair
- ' at the end, hence the "Chr(13) & Chr(10)"
- command = "InputFile(" & INPUT_FILE_NAME & ")" & Chr(13) & Chr(10) & _
- "OutputFile(" & OUTPUT_FILE_NAME & ")" & Chr(13) & Chr(10) & _
- "Drives(c:)" & Chr(13) & Chr(10) & _
- "FileType(FIXED,20)" & Chr(13) & Chr(10) & _
- "Key(Generic,ASC,0,0,20)"
- ' Execute sort using the settings in "command"
- result = SSICreateFromCommandString(handle, command, cmdstate)
- If (result <> SOSOERR_SUCCESS) Then
- ' If we have an error, get the corresponding message
- ' from the library, display it and then return
- ShowErrorMessage (result)
- Exit Sub
- End If
- MousePointer = vbHourglass
- result = SSISort(handle)
- If (result <> SOSOERR_SUCCESS) Then
- ShowErrorMessage (result)
- Else
- MsgBox "Sort completed"
- End If
- result = SSIFree(handle)
- MousePointer = vbDefault
- End Sub
-